﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApp
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            IDAO a = new MyLinq();
            user us = a.checkLogin(this.Login1.UserName, this.Login1.Password);
            if ( us != null)
            {
                Session["username"] = this.Login1.UserName;
                Session["person_id"] = us.id_person;
                Session["company_id"] = us.id_company;
                e.Authenticated = true;
            }
            else
            {
                e.Authenticated = false;
            }
        }
    }
}
